﻿using Microsoft.IdentityModel.Tokens;
using System.Collections.Generic;
using System.Security.Claims;
using System.Threading.Tasks;

namespace Fast.Extensions.Authentication.JwtBearer
{
    /// <summary>
    /// Token Service
    /// </summary>
    public interface ITokenService
    {
        /// <summary>
        /// Token验证参数
        /// </summary>
        TokenValidationParameters TokenValidationParameters { get; }

        /// <summary>
        /// 获取Token
        /// </summary>
        /// <param name="jwtPayload"></param>
        /// <param name="expiredTime"></param>
        /// <returns></returns>
        Task<TokenEntity> TokenAsync(JwtPayload jwtPayload, long? expiredTime = null);

        /// <summary>
        /// 验证 Token
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        Task<TokenValidationResult> ValidateTokenAsync(string token);

        /// <summary>
        /// 刷新Token
        /// </summary>
        /// <param name="refreshToken"></param>
        /// <returns></returns>
        Task<TokenEntity> RefreshTokenAsync(string refreshToken);

        /// <summary>
        /// 将token解析成JwtPayload
        /// </summary>
        /// <param name="token"></param>
        /// <param name="stringValueClaimTypes"></param>
        /// <param name="listValueClaimTypes"></param>
        /// <returns></returns>
        Task<JwtPayload> GetJwtPayloadAsync(string token, List<string> stringValueClaimTypes = null, List<string> listValueClaimTypes = null);
    }
}
